package com.ht.util;

import org.primeframework.jwt.Signer;
import org.primeframework.jwt.domain.JWT;
import org.primeframework.jwt.hmac.HMACSigner;

import java.util.Map;

/**
 * @author hejialun
 * @ClassName OnlyJwtUtil
 * @description: TODO（）
 * @date 2023-08-13-0:51
 * @version: 1.0
 */
public class OnlyJwtUtil {



    public static String createToken(Map<String,Object> map, String secret){
        try {
            Signer signer = HMACSigner.newSHA256Signer(secret);
            JWT jwt = new JWT();
            for (String key : map.keySet()) {
                jwt.addClaim(key, map.get(key));
            }
            return JWT.getEncoder().encode(jwt, signer);
        } catch (Exception e) {
            return "";
        }
    }
}
